package test1;

import java.util.Random;

public class Role {
    private String name;
    private int blood;
    private int maxfuck;



    private int MaxBlood ;
    static int superflag=0;
    public Role() {}
    public Role(String name, int blood) {
        this.name = name;
        this.blood = blood;
        this.maxfuck = Math.min(30-blood/7,30);
        this.MaxBlood = blood;
    }

    public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return this.name;
    }

    public void setBlood(int blood) {
        this.blood = blood;
    }
    public int getBlood() {
        return this.blood;
    }

    public void setMaxBlood(int MAXBlood) {
        this.MaxBlood = MAXBlood;
    }
    public int getMaxBlood() {
        return MaxBlood;
    }

    public void fuck(Role others) {
        Random random = new Random();
        int randomfuck=random.nextInt(this.maxfuck+2);

        randomfuck=others.missButfuck(this,randomfuck);
        if(randomfuck==1) {

        } else if(others.getBlood() - randomfuck > 0) {
            if (superflag==0) {
                fuckskill(this.name);
            }
            others.blood=Math.max((others.getBlood() - randomfuck), 0);
            live(others.getName());
            System.out.print(this.name + "对" + others.getName() + "造成了" + randomfuck + "点伤害,");
            System.out.println("目前"+others.getName()+"血量:"+others.getBlood());
            superflag=0;
        } else{
            if (superflag==0) {
               fuckskill(this.name);
            }
            live(others.getName());
            System.out.print(this.name + "对" + others.getName() + "造成了" + randomfuck + "点伤害,");
            System.out.println(this.name+"干掉了"+others.getName());
            others.setBlood(0);
            superflag=0;
        }
        //1说明触发反弹,不需要再处理
        //正常返回值判断是否对方血量受伤害后大于0
    }

    public int missButfuck(Role others, int fuck) {
        Random random = new Random();
        int flag = random.nextInt(this.getMaxBlood()+1);
        if(flag<=20&&flag>=6&&this.MaxBlood<=150) {
            System.out.println("正当"+others.getName()+"要出招时,"+this.getName()+"大笑一声,使用宇智波反弹,血量只减少一点,且将受到的伤害反弹给"+others.getName()+"!!!");
            this.setBlood(this.getBlood()-1);
            System.out.println("目前"+this.getName()+"血量:"+this.getBlood());
            flag = random.nextInt(3*this.getMaxBlood()+1);
            if(flag<=20&&flag>=6&&others.blood<=150){
                System.out.println("什么,"+others.getName()+"使用了超级反弹,血量不变,且将"+this.getName()+"的反弹伤害再次反弹了!!!!!");
                superflag=1;
                return fuck;
            }
            live(others.getName());
            System.out.print(this.name + "通过反弹对" + others.getName() + "造成了" + fuck + "点伤害,");
            others.setBlood(Math.max(others.getBlood()-fuck,0));
            System.out.println("目前"+others.getName()+"血量:"+others.getBlood());
            if(others.getBlood()==0){
                System.out.println(this.name+"干掉了"+others.getName());
                others.setBlood(0);
            }
            return 1;
        }
        return fuck;
        //反弹成功返回1,受到1点伤害
        //反弹失败返回正常伤害值
        //对方超级反弹,我方受到1点伤害,返回正常伤害值
    }
    public static void live(String person){
        String[] strings=new String[] {
                person+"使劲浑身解数,尽力躲闪一切攻击,但好像一下都没躲掉...",
                "刹那间,"+person+"识破了对方的攻击,并且结结实实地吃下了所有伤害...",
                "什么,是\"闪\","+person+"掏出了一张三国杀里的\"闪\",但这好像并没有什么用...",
                person+"直接反应了攻击,但并没有躲开,他忘记他不能虚化了...",
                person+"似乎觉醒了蜘蛛感应,但很遗憾即使他能感受到,他也躲不掉任何伤害...",
                "\"啪\"地一声,"+person+"摔倒在地上,此时他已如风中残烛...",
                person+"无能为力,他只能气愤地喊道\"该你赢吗?\"....",
                person+"双手交叉挡下了对方的攻击,可是突然----\"是脱手普攻,坐在台下的人是谁!!!\"...",
                person+"吃惊地瞪着对方,\"我如果用反弹你不就炸了吗,老弟\"..."
        };
        Random random = new Random();
        int choice = random.nextInt ( strings.length);
        System.out.println(strings[choice]);
    }
    public static void fuckskill(String person) {
        String[] strings=new String[] {
                "还未看得清"+person+"的动作,声音已经传来\"霸体螺旋丸!\"...",
                person+"双手摊开,\"一袋米要扛几楼?---神罗天征\"...",
                person+"歪嘴一笑,\"贝壳起手,如何呢\",\"替身对吗,孩子,我直接飞天接一如何呢,老弟\"...",
                "只见"+person+"小手一挥,\"靠赛要接,移动马桶!!!\"",
                person+"使用了十万伏特,效果拔群!...",
                person+"看到对方似乎难以战胜,直接一个滑铲,想要铲下对手,但是失败了...",
                "什么,"+person+"使用了【铁山靠】,对方大吃一惊,\"是坤拳,是一度无敌于江湖的坤拳!\"...",
                "什么,"+person+"打出了一张\"杀\",正在对手懵逼之际,直接给了对方一拳"
        };
        Random random = new Random();
        int choice = random.nextInt ( strings.length);
        System.out.println(strings[choice]);
    }
}

